
<?php 
	include_once("web_header.php");
?>

<div class="web_wrap">
    <div class="reg_content_wrap">
         <h4>登录到教练中心</h4>

         <div style="width:500px; margin:auto;margin-top:40px;">

				<form class="form-horizontal" role="form">
 
				   <div class="form-group">
				      <label for="firstname" class="col-sm-2 control-label">帐号</label>
				      <div class="col-sm-10">
				         <input type="text" class="form-control" id="phonenumber" 
				            placeholder="请输入注册手机号">
				      </div>
				   </div>

 
				   <div class="form-group">
				      <label for="lastname" class="col-sm-2 control-label">密码</label>
				      <div class="col-sm-10">
				         <input type="password" class="form-control" id="password" 
				            placeholder="请设置训练日登录密码">
				      </div>
				   </div>
 


				   <div class="form-group">
				      <div class="col-sm-offset-2 col-sm-10">
				           <button type="button" id="loginbtn" class="btn btn-primary">登录</button>
 				           <button type="button" id="regbtn" style="float:right" class="btn btn-link">还没注册?</button>
				      </div>
				   </div>
				</form>

         </div>

    </div>
</div>


<script type="text/javascript">

			var wait=60;
		    function time(o) {
		        if (wait == 0) {
		        	$(o).removeClass('un');  
		            $(o).text("重新获取");
		            wait = 60;
		            $('.yy_tit').show();
		            $('.code_box').css("margin-top",0);
		        }else if(wait == 30){
		        	//$('.yy_tit').show();
		            //$('.code_box').css("margin-top",0);
		            $(o).text(wait+"秒");
		            wait--;
		            setTimeout(function() {
		                time(o)
		            },
		            1000);
		        } else {
		        	$(o).addClass('un');
		            $(o).text(wait+"秒");
		            wait--;
		            setTimeout(function() {
		                time(o)
		            },
		            1000);
		        }
		    }

			$('document').ready(function(){

 
 			 	$('#regbtn').bind("click", function(){
			 		 location.href="/index.php/coach/register";
			 	});

			  	//登录
 				$('#loginbtn').bind("click", function(){
					var phonenumber = $('#phonenumber').val();
 					var password = $('#password').val();


					if(phonenumber == "" || phonenumber == undefined){
				         layer.open({
									    content: '请填写电话号码',
									    className: 'bluelayer',
									    time: 2
						 });
						return;
					} 

 					if(password == "" || password == undefined){
				        layer.open({
									    content: '请填写密码',
									    className: 'bluelayer',
									    time: 2
				    	});
						return;
					} 


				    $.ajax({
				            url: '/index.php/coach/login_handle',
				            type: 'POST',
				            data:{phonenumber:phonenumber, password:password},
				            dataType: 'json',
				            error: function(){
				                  alert('Error '); 
				                  posting = false;
				                 },
				            success: function(result){
 
				                if(result.result==1){
				                	location.href="/index.php/coach/web_dashboard";

				                }else{
				                	layer.open({
									    content: '登录失败!请检查手机号或密码',
									    className: 'bluelayer',
									    time: 2
									});

				                } 

				            }

				        });


				});
			});
</script>




<?php 
	include_once("web_footer.php");
?>
